import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

/**
 * Created with Intellij IDEA
 * Description
 * User:ASUS
 * Date:2024-09-08
 * Time:19:58
 */
public class Main {
    public static void main(String[] args) {
        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        System.out.println(list.size());
        //foreach遍历
        for(int e:list){
            System.out.println(e+" ");
        }
        System.out.println();
        //使用迭代器遍历-正向遍历
        ListIterator<Integer> it=list.listIterator();
        while(it.hasNext()){
            System.out.println(it.next()+" ");
        }
        System.out.println();
        //使用反向迭代器-反向遍历
        ListIterator<Integer> rit=list.listIterator();
        while(rit.hasPrevious()){
            System.out.println(rit.hasPrevious()+" ");
        }
        System.out.println();
    }
}
